<?php
/*
 * 进云智能生成平台
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
 */
defined('BY_JYA') or exit('error');
//生成token
	if(!$_SESSION['token']){
		$_SESSION['token']=random(30);
	}
	$wechat=model('core/web')->get_manage_wechat();
	//判断是否来自H5app,openid清空
	if(($_RQ['fromh5wxapp'] && !$_SESSION['isopenid']) || ($_SESSION['openid'] && $_SESSION['wechatopenid'] && $_SESSION['wechatopenid']!=$_SESSION['openid'])){
		$_SESSION['isopenid']=true;
		$getopenid=1;
		$_SESSION['openid']='';
		$_SESSION['isauth_base']='';
	}
	if($wechat){
		$_SESSION['wechat_id']=$wechat['id'];
		//没登录或者第一次fromh5wxapp的访问，同时是认证服务号
		if($wechat['type']== '4' && (!$_SESSION['uid'] || $getopenid)){
			$_SESSION['after_auth_url']=$_AR['siteurl'];
			if(!$_SESSION['openid'] && $_SESSION['isauth_base']!=1){
					$url=model('core/member')->wechat_auth_base_url();
					if($url){
							header('location:'.$url);exit;
					}
			}elseif($_SESSION['openid'] && $_SESSION['islogout']!=1 && $_SESSION['isauth_info']!=1 && $_SESSION['fromh5wxapp']!=1){
					$url=model('core/member')->wechat_auth_info_url();
					if($url){
							header('location:'.$url);exit;
					}
			}
		}
	}

